﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using BlueLotus7.ArchiveSystem.IMStatusMonitor.Properties;

namespace BlueLotus7.ArchiveSystem.IMStatusMonitor
{
    partial class IMStatusMonitorService : ServiceBase
    {
        StatusMonitorContainer container = null;
        public IMStatusMonitorService()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            try
            {
                container = new StatusMonitorContainer(Settings.Default.ClientIdentity);
                Global.Logger.LogMessageWithTimestamp("Initialized successfully");
            }
            catch (Exception ex)
            {
                Global.Logger.LogException("Fail to initialize monitor container: " + Settings.Default.ClientIdentity.ToString(), ex);
            }

            if (container != null)
            {
                container.Start();
            }
        }

        protected override void OnStop()
        {
            // TODO: Add code here to perform any tear-down necessary to stop your service.
        }
    }
}
